<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义指令——设置背景色</title>
</head>
<body>
<div id="app">
    <h1 v-highlight="'green'">Hello， World！</h1>
    <h1 v-highlight="color">Hello， World！</h1>
</div>

<script type="module">
    import {createApp, ref} from "../../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {
                let color = "green"
                return {
                    color,
                }
            }
        }
    )

    app.directive(
        "highlight",
        {
            created(el, binding){
                // el.style.backgroundColor= "yellow"
                el.style.backgroundColor = binding.value
            }

        }
    )
    app.mount("#app")
</script>
</body>
</html>